[geany/geany-plugins] 7ba298: geanyinsertnum - compatibility with gtk+ 3
Dimitar Zhekov
git-noreply at xxxxx
Sat Apr 6 15:07:32 UTC 2013
Branch: refs/heads/master
Author: Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer: Dimitar Zhekov <dimitar.zhekov at gmail.com>
Date: Sat, 06 Apr 2013 15:07:32 UTC
Commit: 7ba298ae1587d8d2a0d297dee851e9b983f6a0ff
https://github.com/geany/geany-plugins/commit/7ba298ae1587d8d2a0d297dee851e9b983f6a0ff
Log Message:
-----------
geanyinsertnum - compatibility with gtk+ 3
Modified Paths:
--------------
build/geanyinsertnum.m4
geanyinsertnum/ChangeLog
geanyinsertnum/src/insertnum.c
Modified: build/geanyinsertnum.m4
1 files changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -1,7 +1,6 @@
AC_DEFUN([GP_CHECK_GEANYINSERTNUM],
[
GP_ARG_DISABLE([GeanyInsertNum], [auto])
- GP_CHECK_PLUGIN_GTK2_ONLY([GeanyInsertNum])
GP_COMMIT_PLUGIN_STATUS([GeanyInsertNum])
AC_CONFIG_FILES([
geanyinsertnum/Makefile
Modified: geanyinsertnum/ChangeLog
16 files changed, 15 insertions(+), 1 deletions(-)
===================================================================
@@ -1,3 +1,17 @@
+2013-04-06 Dimitar Zhekov <dimitar.zhekov at gmail.com>
+
+ * src/insertnum.c:
+ Fixed some space indentation.
+ Changes to use GtkGrid under GTK+ 3.
+ Defined GTK_COMPAT_H to avoid inclusion of gtkcompat.h and
+ defined the macros required for GTK+ 2/3 compatibility.
+
+2013-04-06 Quentin Glidic <sardemff7+git at sardemff7.net>
+
+ * src/insertnum.c:
+ Changes to compile with GTK+ 3: GtkComboBoxText and
+ gtk_widget_set_can_default().
+
2011-02-23 Dimitar Zhekov <dimitar.zhekov at gmail.com>
* src/insertnum.c:
@@ -23,4 +37,4 @@
2010-03-12 Dimitar Zhekov <hamster at mbox.contact.bg>
* src/insertnum.c:
- Small changes to compile with GTK 2.8 / Win32.
+ Small changes to compile with GTK+ 2.8 / Win32.
Modified: geanyinsertnum/src/insertnum.c
87 files changed, 59 insertions(+), 28 deletions(-)
===================================================================
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
+#define GTK_COMPAT_H
#include "geanyplugin.h"
GeanyPlugin *geany_plugin;
@@ -108,7 +109,7 @@ static gboolean can_insert_numbers(void)
static void update_display(void)
{
while (gtk_events_pending())
- gtk_main_iteration();
+ gtk_main_iteration();
}
#define sci_point_x_from_position(sci, position) \
@@ -141,7 +142,7 @@ static void insert_numbers(gboolean *cancel)
/* lines shorter than the current selection are skipped */
for (line = start_line, i = 0; line <= end_line; line++, i++)
{
- if (sci_point_x_from_position(sci,
+ if (sci_point_x_from_position(sci,
scintilla_send_message(sci, SCI_GETLINEENDPOSITION, line, 0)) >= xinsert)
{
line_pos[i] = sci_get_pos_at_line_sel_start(sci, line) -
@@ -308,13 +309,29 @@ static void set_entry(GtkWidget *entry, gint maxlen, GtkWidget *label, const gch
ui_widget_set_tooltip_text(entry, tooltip);
}
+#if !GTK_CHECK_VERSION(2, 24, 0)
+#define GtkComboBoxText GtkComboBox
+#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
+#define gtk_combo_box_text_new_with_entry gtk_combo_box_entry_new_text
+#define gtk_combo_box_text_append_text gtk_combo_box_append_text
+#endif
+
+#if !GTK_CHECK_VERSION(3, 0, 0)
+#define GtkGrid GtkTable
+#define GTK_GRID GTK_TABLE
+#define gtk_grid_attach(grid, child, left, top, width, height) \
+ gtk_table_attach_defaults(grid, child, left, left + width, top, top + height)
+#define gtk_grid_set_row_spacing gtk_table_set_row_spacings
+#define gtk_grid_set_column_spacing gtk_table_set_col_spacings
+#endif
+
static void on_insert_numbers_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED
gpointer gdata)
{
InsertNumbersDialog d;
GtkWidget *vbox, *label, *upper, *space, *button;
- GtkTable *table;
- GtkComboBox *combo;
+ GtkGrid *grid;
+ GtkComboBoxText *combo;
const char *case_tip = _("For base 11 and above");
gchar *base_text;
gint result;
@@ -333,63 +350,77 @@ static void on_insert_numbers_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GN
vbox = ui_dialog_vbox_new(GTK_DIALOG(d.dialog));
gtk_box_set_spacing(GTK_BOX(vbox), 9);
- table = GTK_TABLE(gtk_table_new(3, 6, FALSE));
- gtk_table_set_row_spacings(table, 6);
- gtk_table_set_col_spacings(table, 6);
- gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(table), TRUE, TRUE, 0);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ grid = GTK_GRID(gtk_grid_new());
+#else
+ grid = GTK_TABLE(gtk_table_new(3, 6, FALSE));
+#endif
+ gtk_grid_set_row_spacing(grid, 6);
+ gtk_grid_set_column_spacing(grid, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(grid), TRUE, TRUE, 0);
label = gtk_label_new_with_mnemonic(_("_Start:"));
- gtk_table_attach_defaults(table, label, 0, 1, 0, 1);
+ gtk_grid_attach(grid, label, 0, 0, 1, 1);
d.start = gtk_spin_button_new_with_range(RANGE_MIN, RANGE_MAX, 1);
set_entry(d.start, RANGE_LEN, label, RANGE_TOOLTIP);
- gtk_table_attach_defaults(table, d.start, 1, 3, 0, 1);
+ gtk_grid_attach(grid, d.start, 1, 0, 2, 1);
label = gtk_label_new_with_mnemonic(_("S_tep:"));
- gtk_table_attach_defaults(table, label, 3, 4, 0, 1);
+ gtk_grid_attach(grid, label, 3, 0, 1, 1);
d.step = gtk_spin_button_new_with_range(RANGE_MIN, RANGE_MAX, 1);
set_entry(d.step, RANGE_LEN, label, RANGE_TOOLTIP);
- gtk_table_attach_defaults(table, d.step, 4, 6, 0, 1);
+ gtk_grid_attach(grid, d.step, 4, 0, 2, 1);
label = gtk_label_new_with_mnemonic(_("_Base:"));
- gtk_table_attach_defaults(table, label, 0, 1, 1, 2);
- combo = GTK_COMBO_BOX(gtk_combo_box_entry_new_text());
+ gtk_grid_attach(grid, label, 0, 1, 1, 1),
+ combo = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new_with_entry());
d.base = gtk_bin_get_child(GTK_BIN(combo));
set_entry(d.base, 2, label, "2..36");
g_signal_connect(d.base, "insert-text", G_CALLBACK(on_base_insert_text), NULL);
- gtk_combo_box_append_text(combo, "2");
- gtk_combo_box_append_text(combo, "8");
- gtk_combo_box_append_text(combo, "10");
- gtk_combo_box_append_text(combo, "16");
- gtk_table_attach(table, GTK_WIDGET(combo), 1, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ gtk_combo_box_text_append_text(combo, "2");
+ gtk_combo_box_text_append_text(combo, "8");
+ gtk_combo_box_text_append_text(combo, "10");
+ gtk_combo_box_text_append_text(combo, "16");
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_grid_attach(grid, GTK_WIDGET(combo), 1, 1, 2, 1);
+ gtk_widget_set_hexpand(GTK_WIDGET(combo), TRUE);
+#else
+ gtk_table_attach(grid, GTK_WIDGET(combo), 1, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+#endif
label = gtk_label_new(_("Letters:"));
ui_widget_set_tooltip_text(label, case_tip);
- gtk_table_attach_defaults(table, label, 3, 4, 1, 2);
+ gtk_grid_attach(grid, label, 3, 1, 1, 1);
upper = gtk_radio_button_new_with_mnemonic(NULL, _("_Upper"));
ui_widget_set_tooltip_text(upper, case_tip);
- gtk_table_attach_defaults(table, upper, 4, 5, 1, 2);
+ gtk_grid_attach(grid, upper, 4, 1, 1, 1);
d.lower = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(upper));
ui_widget_set_tooltip_text(label, case_tip);
label = gtk_label_new_with_mnemonic(_("_Lower"));
ui_widget_set_tooltip_text(label, case_tip);
gtk_container_add(GTK_CONTAINER(d.lower), label);
- gtk_table_attach_defaults(table, d.lower, 5, 6, 1, 2);
+ gtk_grid_attach(grid, d.lower, 5, 1, 1, 1);
d.prefix = gtk_check_button_new_with_mnemonic(_("Base _prefix"));
ui_widget_set_tooltip_text(d.prefix,
_("0 for octal, 0x for hex, + for positive decimal"));
- gtk_table_attach_defaults(table, d.prefix, 1, 3, 2, 3);
+ gtk_grid_attach(grid, d.prefix, 1, 2, 2, 1);
label = gtk_label_new(_("Padding:"));
- gtk_table_attach_defaults(table, label, 3, 4, 2, 3);
+ gtk_grid_attach(grid, label, 3, 2, 1, 1);
space = gtk_radio_button_new_with_mnemonic(NULL, _("Sp_ace"));
- gtk_table_attach_defaults(table, space, 4, 5, 2, 3);
+ gtk_grid_attach(grid, space, 4, 2, 1, 1);
d.zero = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(space));
label = gtk_label_new_with_mnemonic(_("_Zero"));
gtk_container_add(GTK_CONTAINER(d.zero), label);
- gtk_table_attach_defaults(table, d.zero, 5, 6, 2, 3);
+ gtk_grid_attach(grid, d.zero, 5, 2, 1, 1);
button = gtk_button_new_from_stock(GTK_STOCK_OK);
g_signal_connect(button, "clicked", G_CALLBACK(on_insert_numbers_ok_clicked), &d);
- gtk_box_pack_end(GTK_BOX(GTK_DIALOG(d.dialog)->action_area), button, TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(d.dialog))), button,
+ TRUE, TRUE, 0);
+#if GTK_CHECK_VERSION(2, 18, 0)
+ gtk_widget_set_can_default(button, TRUE);
+#else
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+#endif
gtk_widget_grab_default(button);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(d.start), start_value);
@@ -418,7 +449,7 @@ static void on_insert_numbers_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GN
{
gboolean cancel = FALSE;
- gtk_widget_set_sensitive(GTK_WIDGET(table), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(grid), FALSE);
gtk_widget_set_sensitive(button, FALSE);
update_display();
g_signal_connect(d.dialog, "response",
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list