Include a Other Software section in Help file
[geeqie.git] / src / ui_misc.c
index 461e1ee..c2d59b8 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * (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
@@ -27,6 +36,7 @@
 
 #include "history_list.h"
 
+#include <langinfo.h>
 
 /*
  *-----------------------------------------------------------------------------
@@ -79,7 +89,12 @@ GtkWidget *pref_group_new(GtkWidget *parent_box, gboolean fill,
        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);
@@ -255,7 +270,12 @@ GtkWidget *pref_button_new(GtkWidget *parent_box, const gchar *stock_id,
                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);
                        }
 
@@ -1030,15 +1050,43 @@ GtkWidget *date_selection_new(void)
        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();
@@ -1163,7 +1211,7 @@ static gint sizer_default_handle_size(void)
        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;
@@ -1172,8 +1220,8 @@ static gboolean sizer_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpoin
 
        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;
@@ -1694,4 +1742,69 @@ gchar *text_widget_text_pull(GtkWidget *text_widget)
 
 }
 
+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: */