Allow to click on heading to ellipsize it

This commit is contained in:
Markus Koch 2017-09-02 10:48:14 +02:00
parent eeb9d87cc3
commit 6555b8d8e2
3 changed files with 42 additions and 7 deletions

View File

@ -317,17 +317,22 @@
<property name="margin_right">4</property> <property name="margin_right">4</property>
<property name="margin_top">2</property> <property name="margin_top">2</property>
<property name="margin_bottom">2</property> <property name="margin_bottom">2</property>
<child>
<object class="GtkEventBox" id="summaryEventBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child> <child>
<object class="GtkLabel" id="labelSummary"> <object class="GtkLabel" id="labelSummary">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Please select an entry in the list above.</property> <property name="label" translatable="yes">Please select an entry in the list above.</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<attributes> <attributes>
<attribute name="scale" value="1.3999999999999999"/> <attribute name="scale" value="1.3999999999999999"/>
</attributes> </attributes>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>

View File

@ -412,6 +412,11 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"clicked", "clicked",
(GCallback) mainWindow_decrypt_gpg_clicked, (GCallback) mainWindow_decrypt_gpg_clicked,
mainWindow); mainWindow);
g_signal_connect(mainWindow->summaryEventBox,
"button-press-event",
(GCallback) mainWindow_toggleSummaryWrap,
mainWindow);
} }
/** /**
@ -541,6 +546,7 @@ struct mainWindow *mainWindow_new()
mainWindow->checkSearchSummary = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchSummary")); mainWindow->checkSearchSummary = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchSummary"));
mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags")); mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags"));
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText")); mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
mainWindow->summaryEventBox = GTK_WIDGET(gtk_builder_get_object(builder, "summaryEventBox"));
mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary")); mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary"));
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch")); mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
mainWindow->headerBar = GTK_WIDGET(gtk_builder_get_object(builder, "headerBar")); mainWindow->headerBar = GTK_WIDGET(gtk_builder_get_object(builder, "headerBar"));
@ -1038,3 +1044,25 @@ void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data)
g_print("ERROR: This should never happen...\n"); g_print("ERROR: This should never happen...\n");
} }
} }
/**
* @brief mainWindow_toggleSummaryWrap toggles line-wrapping and ellipsize on the summary
* @param widget
* @param event
* @param user_data
* @return
*/
gboolean mainWindow_toggleSummaryWrap(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
gboolean state;
state = gtk_label_get_line_wrap(GTK_LABEL(mainWindow->labelSummary));
gtk_label_set_ellipsize(GTK_LABEL(mainWindow->labelSummary),
!state ? PANGO_ELLIPSIZE_NONE : PANGO_ELLIPSIZE_END);
gtk_label_set_line_wrap(GTK_LABEL(mainWindow->labelSummary), !state);
return FALSE;
}

View File

@ -37,6 +37,7 @@ struct mainWindow {
GtkWidget *checkSearchSummary; GtkWidget *checkSearchSummary;
GtkWidget *checkSearchTags; GtkWidget *checkSearchTags;
GtkWidget *checkSearchText; GtkWidget *checkSearchText;
GtkWidget *summaryEventBox;
GtkWidget *labelSummary; GtkWidget *labelSummary;
GtkWidget *buttonClearSearch; GtkWidget *buttonClearSearch;
GtkWidget *headerBar; GtkWidget *headerBar;
@ -108,5 +109,6 @@ void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gbo
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data); void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data);
void mainWindow_renderer_set(struct mainWindow *mainWindow, enum renderer_mode state); void mainWindow_renderer_set(struct mainWindow *mainWindow, enum renderer_mode state);
void mainWindow_settings_show(struct mainWindow *mainWindow); void mainWindow_settings_show(struct mainWindow *mainWindow);
gboolean mainWindow_toggleSummaryWrap(GtkWidget *widget, GdkEvent *event, gpointer user_data);
#endif /* MAINWINDOW_H */ #endif /* MAINWINDOW_H */