/*
- * (SLIK) SimpLIstic sKin functions
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
*
* Author: John Ellis
*
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
#include "history_list.h"
+#include <langinfo.h>
/*
*-----------------------------------------------------------------------------
gtk_widget_show(vbox);
label = gtk_label_new(text);
+#if GTK_CHECK_VERSION(3,16,0)
+ gtk_label_set_xalign(GTK_LABEL(label), 0.0);
+ gtk_label_set_yalign(GTK_LABEL(label), 0.5);
+#else
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+#endif
pref_label_bold(label, TRUE, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
if (text)
{
label = gtk_label_new_with_mnemonic(text);
+#if GTK_CHECK_VERSION(3,16,0)
+ gtk_label_set_xalign(GTK_LABEL(label), 0.5);
+ gtk_label_set_yalign(GTK_LABEL(label), 0.5);
+#else
gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+#endif
gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
}
G_CALLBACK(pref_spin_int_cb), value_var);
}
-#if 0
-void pref_spin_set_blocking(GtkWidget *spin, gdouble value, gpointer block_data)
-{
- g_signal_handlers_block_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, block_data);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value);
- g_signal_handlers_unblock_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, block_data);
-}
-#endif
-
static void pref_link_sensitivity_cb(GtkWidget *watch, GtkStateType prev_state, gpointer data)
{
GtkWidget *widget = data;
return button;
}
-#if 0
-static GtkWidget *pref_table_checkbox(GtkWidget *table, gint column, gint row,
- const gchar *text, gint active,
- GCallback func, gpointer data)
-{
- GtkWidget *button;
-
- button = gtk_check_button_new_with_label(text);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
- if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
-
- gtk_table_attach(GTK_TABLE(table), button, column, column + 1, row, row + 1,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
- gtk_widget_show(button);
-
- return button;
-}
-#endif
-
GtkWidget *pref_table_spin(GtkWidget *table, gint column, gint row,
const gchar *text, const gchar *suffix,
gdouble min, gdouble max, gdouble step, gint digits,
GtkWidget *pref_toolbar_new(GtkWidget *parent_box, GtkToolbarStyle style)
{
GtkWidget *tbar;
-
+
tbar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(tbar), style);
gtk_widget_get_allocation(ds->button, &button_allocation);
gtk_widget_get_allocation(ds->window, &window_allocation);
-
+
x = wx + button_allocation.x + button_allocation.width - window_allocation.width;
y = wy + button_allocation.y + button_allocation.height;
GtkWidget *arrow;
ds = g_new0(DateSelection, 1);
+ gchar *date_format;
+ gint i;
ds->box = gtk_hbox_new(FALSE, 2);
g_signal_connect(G_OBJECT(ds->box), "destroy",
G_CALLBACK(date_selection_destroy_cb), ds);
- /* FIXME: use option menu with text format of month instead of a spin button */
- ds->spin_m = pref_spin_new(ds->box, NULL, NULL, 1, 12, 1, 0, 1, NULL, NULL);
- ds->spin_d = pref_spin_new(ds->box, NULL, NULL, 1, 31, 1, 0, 1, NULL, NULL);
- ds->spin_y = pref_spin_new(ds->box, NULL, NULL, 1900, 9999, 1, 0, 1900, NULL, NULL);
+ date_format = nl_langinfo(D_FMT);
+
+ if (strlen(date_format) == 8)
+ {
+ for (i=1; i<8; i=i+3)
+ {
+ switch (date_format[i])
+ {
+ case 'd':
+ ds->spin_d = pref_spin_new(ds->box, NULL, NULL, 1, 31, 1, 0, 1, NULL, NULL);
+ break;
+ case 'm':
+ ds->spin_m = pref_spin_new(ds->box, NULL, NULL, 1, 12, 1, 0, 1, NULL, NULL);
+ break;
+ case 'y': case 'Y':
+ ds->spin_y = pref_spin_new(ds->box, NULL, NULL, 1900, 9999, 1, 0, 1900, NULL, NULL);
+ break;
+ default:
+ log_printf("Warning: Date locale %s is unknown", date_format);
+ break;
+ }
+ }
+ }
+ else
+ {
+ ds->spin_m = pref_spin_new(ds->box, NULL, NULL, 1, 12, 1, 0, 1, NULL, NULL);
+ ds->spin_d = pref_spin_new(ds->box, NULL, NULL, 1, 31, 1, 0, 1, NULL, NULL);
+ ds->spin_y = pref_spin_new(ds->box, NULL, NULL, 1900, 9999, 1, 0, 1900, NULL, NULL);
+ }
+
spin_increase(ds->spin_y, 5);
ds->button = gtk_toggle_button_new();
return handle_size;
}
-static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
SizerData *sd = data;
gint x, y;
if (!sd->in_drag) return FALSE;
- x = sd->press_x - bevent->x_root;
- y = sd->press_y - bevent->y_root;
+ x = sd->press_x - event->x_root;
+ y = sd->press_y - event->y_root;
w = sd->press_width;
h = sd->press_height;
}
+gchar *text_widget_text_pull_selected(GtkWidget *text_widget)
+{
+ if (GTK_IS_TEXT_VIEW(text_widget))
+ {
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget));
+ gtk_text_buffer_get_bounds(buffer, &start, &end);
+
+ if (gtk_text_buffer_get_selection_bounds(buffer, &start, &end))
+ {
+ gtk_text_iter_set_line_offset(&start, 0);
+ gtk_text_iter_forward_to_line_end(&end);
+ }
+
+ return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+ }
+ else if (GTK_IS_ENTRY(text_widget))
+ {
+ return g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget)));
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+gboolean defined_mouse_buttons(GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ LayoutWindow *lw = data;
+ GtkAction *action;
+ gboolean ret = FALSE;
+
+ switch (event->button)
+ {
+ case MOUSE_BUTTON_8:
+ if (options->mouse_button_8)
+ {
+ action = gtk_action_group_get_action(lw->action_group, options->mouse_button_8);
+ if (action)
+ {
+ gtk_action_activate(action);
+ }
+ ret = TRUE;
+ }
+ break;
+ case MOUSE_BUTTON_9:
+ if (options->mouse_button_9)
+ {
+ action = gtk_action_group_get_action(lw->action_group, options->mouse_button_9);
+ if (action)
+ {
+ gtk_action_activate(action);
+ }
+ ret = TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */