libreofficekit: add a way to invoke getCommandValues()

- add a new button to the toolbar to invoke the getCommandValues() LOK
  API with user-provided command name (and parameters)

- log the result using g_info(), which is visible on the console if
  gtktiledviewer is started with G_MESSAGES_DEBUG=all

- change some labels to tooltip texts that actually show up on mouse
  hover so you can understand what button does what

- tweak the icons, so the question mark icon is the getter and the info
  icon is the setter

Change-Id: If6984d2dde3d669b42aafcc3f58a0ca757ccaaff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143477
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna 2022-11-30 08:57:50 +01:00
parent 01a3cc1e55
commit 2c149dc998
4 changed files with 55 additions and 3 deletions

View file

@ -129,6 +129,7 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar)
gtk_builder_add_callback_symbol(builder.get(), "getRulerState", G_CALLBACK(getRulerState));
gtk_builder_add_callback_symbol(builder.get(), "recentUnoChanged", G_CALLBACK(recentUnoChanged));
gtk_builder_add_callback_symbol(builder.get(), "unoCommandDebugger", G_CALLBACK(unoCommandDebugger));
gtk_builder_add_callback_symbol(builder.get(), "commandValuesDebugger", G_CALLBACK(commandValuesDebugger));
gtk_builder_add_callback_symbol(builder.get(), "toggleEditing", G_CALLBACK(toggleEditing));
gtk_builder_add_callback_symbol(builder.get(), "changePartMode", G_CALLBACK(changePartMode));
gtk_builder_add_callback_symbol(builder.get(), "changePart", G_CALLBACK(changePart));

View file

@ -284,6 +284,41 @@ void unoCommandDebugger(GtkWidget* pButton, gpointer /* pItem */)
gtk_widget_destroy(pUnoCmdDialog);
}
void commandValuesDebugger(GtkWidget* pButton, gpointer /* pItem */)
{
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pButton));
GtkWidget* pUnoCmdDialog = gtk_dialog_new_with_buttons ("Get command values",
GTK_WINDOW (window),
GTK_DIALOG_MODAL,
"Execute",
GTK_RESPONSE_OK,
nullptr);
g_object_set(G_OBJECT(pUnoCmdDialog), "resizable", FALSE, nullptr);
GtkWidget* pDialogMessageArea = gtk_dialog_get_content_area (GTK_DIALOG (pUnoCmdDialog));
GtkWidget* pUnoCmdAreaBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pUnoCmdAreaBox, true, true, 2);
GtkWidget* pUnoCmdLabel = gtk_label_new("Enter UNO command");
gtk_box_pack_start(GTK_BOX(pUnoCmdAreaBox), pUnoCmdLabel, true, true, 2);
GtkWidget* pUnoCmdEntry = gtk_entry_new ();
gtk_box_pack_start(GTK_BOX(pUnoCmdAreaBox), pUnoCmdEntry, true, true, 2);
gtk_entry_set_placeholder_text(GTK_ENTRY(pUnoCmdEntry), "e.g. .uno:Undo");
gtk_widget_show_all(pUnoCmdDialog);
gint res = gtk_dialog_run (GTK_DIALOG(pUnoCmdDialog));
if (res == GTK_RESPONSE_OK)
{
const gchar* pUnoCmd = gtk_entry_get_text(GTK_ENTRY(pUnoCmdEntry));
gchar* pValues = lok_doc_view_get_command_values(LOK_DOC_VIEW(window->lokdocview), pUnoCmd);
g_info("lok::Document::getCommandValues(%s) : %s", pUnoCmd, pValues);
g_free(pValues);
}
gtk_widget_destroy(pUnoCmdDialog);
}
void toggleEditing(GtkWidget* pButton, gpointer /*pItem*/)
{
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pButton));

View file

@ -26,6 +26,8 @@ void recentUnoChanged(GtkWidget* pSelector, gpointer /* pItem */);
void unoCommandDebugger(GtkWidget* pButton, gpointer /* pItem */);
void commandValuesDebugger(GtkWidget* pButton, gpointer /* pItem */);
void toggleEditing(GtkWidget* pButton, gpointer /*pItem*/);
void changePartMode(GtkWidget* pSelector, gpointer /* pItem */);

View file

@ -470,7 +470,7 @@
<child>
<object class="GtkToggleToolButton" id="btn_editmode">
<property name="visible">True</property>
<property name="label" translatable="yes">Turn on/off edit mode</property>
<property name="tooltip_text">Turn on/off edit mode</property>
<property name="use_underline">True</property>
<property name="icon_name">insert-text-symbolic</property>
<signal name="clicked" handler="toggleEditing" swapped="no"/>
@ -493,6 +493,7 @@
<child>
<object class="GtkToolItem" id="recentunoselectortoolitem">
<property name="visible">True</property>
<property name="tooltip_text">Recent UNO command selector</property>
<property name="can_focus">False</property>
<child>
<object class="GtkComboBoxText" id="combo_recentunoselector">
@ -514,10 +515,23 @@
<child>
<object class="GtkToolButton" id="btn_unodebugger">
<property name="visible">True</property>
<property name="label" translatable="yes">Uno Command Debugger</property>
<property name="tooltip_text">Uno Command Debugger</property>
<property name="use_underline">True</property>
<property name="icon_name">dialog-information-symbolic</property>
<signal name="clicked" handler="unoCommandDebugger" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="btn_commandvaluesdebugger">
<property name="visible">True</property>
<property name="tooltip_text">Command values Debugger</property>
<property name="use_underline">True</property>
<property name="icon_name">dialog-question-symbolic</property>
<signal name="clicked" handler="unoCommandDebugger" swapped="no"/>
<signal name="clicked" handler="commandValuesDebugger" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>