Skip to content

Commit

Permalink
Clicky: Prepare for gtk3 by removing gtk2 deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Jan 20, 2015
1 parent d984500 commit 392b1f6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 43 deletions.
4 changes: 2 additions & 2 deletions apps/clicky/src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in

INCLUDES = \
AM_CPPFLAGS = \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
@PACKAGE_CFLAGS@ \
Expand All @@ -9,7 +9,6 @@ INCLUDES = \
bin_PROGRAMS = clicky

clicky_SOURCES = \
interface.c interface.h \
support.c support.h \
gathererror.cc gathererror.hh \
permstr.cc permstr.hh \
Expand All @@ -30,6 +29,7 @@ clicky_SOURCES = \
transform.cc transform.hh \
ref.hh \
clicky.cc \
interface.c interface.h \
callbacks.h \
xcallbacks.c

Expand Down
3 changes: 2 additions & 1 deletion apps/clicky/src/clicky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "dstyle.hh"
#include <click/hashtable.hh>
#include <netdb.h>
#include <locale.h>

extern "C" {
#include "interface.h"
Expand Down Expand Up @@ -123,7 +124,7 @@ main(int argc, char *argv[])
if (gtkrc_file)
gtk_rc_add_default_file(gtkrc_file.c_str());

gtk_set_locale();
setlocale(LC_ALL, "");
bool have_gui = gtk_init_check(&argc, &argv);
add_pixmap_directory(PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");

Expand Down
29 changes: 11 additions & 18 deletions apps/clicky/src/dialogs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,41 @@ static void on_new_window_activate(GtkMenuItem *, gpointer user_data)
rw->show();
}

static void on_open_file_activate(GtkMenuItem *, gpointer user_data)
{
static void on_open_file_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->on_open_file();
}

static void on_open_socket_activate(GtkMenuItem *, gpointer user_data)
{
static void on_open_socket_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->on_open_socket();
}

static void on_open_kernel_activate(GtkMenuItem *, gpointer user_data)
{
static void on_open_kernel_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->on_open_kernel();
}

static void on_save_activate(GtkMenuItem *, gpointer user_data)
{
static void on_save_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->on_save_file(false);
}

static void on_save_as_activate(GtkMenuItem *, gpointer user_data)
{
static void on_save_as_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->on_save_file(true);
}

static void on_export_diagram_activate(GtkMenuItem *, gpointer user_data)
{
static void on_export_diagram_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->on_export_diagram();
}

static void on_quit_activate(GtkMenuItem *, gpointer)
{
static void on_quit_activate(GtkMenuItem *, gpointer) {
while (wmain::all_wmains.size())
delete wmain::all_wmains[0];
gtk_main_quit();
}

static void on_check_activate(GtkMenuItem *, gpointer user_data)
{
static void on_check_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->config_check(false);
}

static void on_install_activate(GtkMenuItem *, gpointer user_data)
{
static void on_install_activate(GtkMenuItem *, gpointer user_data) {
reinterpret_cast<wmain *>(user_data)->config_check(true);
}

Expand Down
6 changes: 3 additions & 3 deletions apps/clicky/src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <string.h>
#include <stdio.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

#include "callbacks.h"
#include "interface.h"
Expand Down Expand Up @@ -101,12 +101,12 @@ create_opensocketdialog (void)
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_show (cancelbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (opensocketdialog), cancelbutton1, GTK_RESPONSE_CANCEL);
GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
gtk_widget_set_can_default (cancelbutton1, TRUE);

okbutton1 = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_show (okbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (opensocketdialog), okbutton1, GTK_RESPONSE_OK);
GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
gtk_widget_set_can_default (okbutton1, TRUE);

/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (opensocketdialog, opensocketdialog, "opensocketdialog");
Expand Down
2 changes: 1 addition & 1 deletion apps/clicky/src/wdiagram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void wdiagram::router_create(bool incremental, bool always)
_cdiagram = 0;
}
// don't bother creating if widget not mapped
if (!always && !GTK_WIDGET_VISIBLE(_widget))
if (!always && !gtk_widget_get_visible(_widget))
return;
if (!_cursor[0])
initialize();
Expand Down
2 changes: 1 addition & 1 deletion apps/clicky/src/wdiagram.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class wdiagram { public:
void router_create(bool incremental, bool always);

bool visible() const {
return GTK_WIDGET_VISIBLE(_widget);
return gtk_widget_get_visible(_widget);
}

inline void redraw();
Expand Down
16 changes: 8 additions & 8 deletions apps/clicky/src/whandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ int whandler::hinfo::create_display(whandler *wh)
} else {
wadd = wdata = gtk_entry_new();
if (!hv->editable()) {
gtk_entry_set_editable(GTK_ENTRY(wdata), FALSE);
gtk_editable_set_editable(GTK_EDITABLE(wdata), FALSE);
g_object_set(wdata, "can-focus", FALSE, (const char *) NULL);
} else if (wh->active()) {
g_signal_connect(wdata, "event", G_CALLBACK(on_handler_event), wh);
Expand Down Expand Up @@ -371,7 +371,7 @@ void whandler::hinfo::display(whandler *wh, bool change_form)
if (!(hv->flags() & hflag_multiline) && (multiline || positions.size())) {
if (!change_form) {
gtk_entry_set_text(GTK_ENTRY(wdata), "???");
gtk_entry_set_position(GTK_ENTRY(wdata), -1);
gtk_editable_set_position(GTK_EDITABLE(wdata), -1);
return;
} else
create(wh, hv->flags() | hflag_multiline, false);
Expand All @@ -398,7 +398,7 @@ void whandler::hinfo::display(whandler *wh, bool change_form)
gtk_text_buffer_place_cursor(b, &i1);
} else {
gtk_entry_set_text(GTK_ENTRY(wdata), hv->hvalue().c_str());
gtk_entry_set_position(GTK_ENTRY(wdata), -1);
gtk_editable_set_position(GTK_EDITABLE(wdata), -1);
}

// Display parameters
Expand Down Expand Up @@ -428,7 +428,7 @@ void whandler::hinfo::display(whandler *wh, bool change_form)
void whandler::display(const String &ename, bool incremental)
{
if ((_display_ename == ename && incremental)
|| !GTK_WIDGET_DRAWABLE(_eviewbox))
|| !gtk_widget_get_window(_eviewbox))
return;
_display_ename = ename;
gtk_container_foreach(GTK_CONTAINER(_handlerbox), destroy_callback, NULL);
Expand Down Expand Up @@ -651,17 +651,17 @@ void whandler::show_actions(GtkWidget *near, const String &hname, bool changed)

// get monitor and widget coordinates
gtk_widget_realize(near);
GdkScreen *screen = gdk_drawable_get_screen(near->window);
GdkScreen *screen = gdk_window_get_screen(near->window);
gint monitor_num = gdk_screen_get_monitor_at_window(screen, near->window);
GdkRectangle monitor;
gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor);

while (GTK_WIDGET_NO_WINDOW(near))
while (!gtk_widget_get_has_window(near))
near = near->parent;
gint near_x1, near_y1, near_x2, near_y2;
gdk_window_get_origin(near->window, &near_x1, &near_y1);
gdk_drawable_get_size(near->window, &near_x2, &near_y2);
near_x2 += near_x1, near_y2 += near_y1;
near_x2 = near_x1 + gdk_window_get_width(near->window);
near_y2 = near_y1 + gdk_window_get_height(near->window);

// get action area requisition
int which = (hi->writable() ? 0 : 1);
Expand Down
21 changes: 12 additions & 9 deletions apps/clicky/src/wmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static gboolean on_error_view_event(GtkWidget *, GdkEvent *, gpointer);
}

String wmain::last_savefile;
static int num_main_windows = 0;
Vector<wmain*> wmain::all_wmains;

extern "C" {
static void destroy(gpointer data) {
Expand Down Expand Up @@ -147,12 +147,10 @@ wmain::wmain(bool show_toolbar, bool show_list, dcss_set *ccss,
set_diagram_mode(false, true);
on_driver_changed();

gtk_quit_add_destroy(1, GTK_OBJECT(_window));
++num_main_windows;
all_wmains.push_back(this);
}

wmain::~wmain()
{
wmain::~wmain() {
// only call from GtkWidget destruction
clear(false);

Expand All @@ -164,7 +162,12 @@ wmain::~wmain()
delete _diagram;
delete _handlers;

if (!--num_main_windows)
for (int i = 0; i != all_wmains.size(); ++i)
if (all_wmains[i] == this) {
all_wmains.erase(all_wmains.begin() + i);
break;
}
if (!all_wmains.size())
gtk_main_quit();
}

Expand Down Expand Up @@ -585,7 +588,7 @@ void wmain::element_show(String ename, int expand, bool incremental)
// expand and highlight whether or not viewed element changed
if (expand != 0) {
GtkWidget *n = lookup_widget(_window, "eviewbox");
if (expand > 0 && !GTK_WIDGET_VISIBLE(n)) {
if (expand > 0 && !gtk_widget_get_visible(n)) {
gtk_widget_show(n);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(_window, "menu_view_element")), TRUE);
GtkPaned *paned = GTK_PANED(lookup_widget(_window, "eviewpane"));
Expand Down Expand Up @@ -963,8 +966,8 @@ void wmain::on_error(bool replace, const String &dialog)
gtk_widget_hide(lookup_widget(_window, "elementtreesort"));
gtk_paned_set_position(pane, 2147483647);
}
gtk_expander_set_expanded(GTK_EXPANDER(treeexpander), GTK_WIDGET_VISIBLE(treewindow));
if ((!gerrh->nerrors() || !replace) && GTK_WIDGET_VISIBLE(treewindow))
gtk_expander_set_expanded(GTK_EXPANDER(treeexpander), gtk_widget_get_visible(treewindow));
if ((!gerrh->nerrors() || !replace) && gtk_widget_get_visible(treewindow))
gtk_paned_set_position(pane, GTK_WIDGET(pane)->allocation.height / 3);

// strip filename errors from error list
Expand Down
2 changes: 2 additions & 0 deletions apps/clicky/src/wmain.hh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class wmain : public crouter { public:
ElementT *element;
};

static Vector<wmain*> all_wmains;

private:

// router
Expand Down

0 comments on commit 392b1f6

Please sign in to comment.