[yast-commit] r51671 - in /trunk/gtk: ChangeLog src/YGDialog.cc src/YGDialog.h src/YGDumbTab.cc src/YGMenuButton.cc src/YGUtils.h src/YGWizard.cc src/ygtkwizard.c
Author: rpmcruz Date: Mon Sep 29 17:08:12 2008 New Revision: 51671 URL: http://svn.opensuse.org/viewcvs/yast?rev=51671&view=rev Log: * src/ygtkwizard.h/c & src/YGDialog.h/cc: use dialog directly to set title/icon. * src/YGWizard.cc: support for setDialogTitle(). Modified: trunk/gtk/ChangeLog trunk/gtk/src/YGDialog.cc trunk/gtk/src/YGDialog.h trunk/gtk/src/YGDumbTab.cc trunk/gtk/src/YGMenuButton.cc trunk/gtk/src/YGUtils.h trunk/gtk/src/YGWizard.cc trunk/gtk/src/ygtkwizard.c Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Mon Sep 29 17:08:12 2008 @@ -1,3 +1,10 @@ +2008-09-29 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + + * src/ygtkwizard.h/c & src/YGDialog.h/cc: use dialog directly + to set title/icon. + + * src/YGWizard.cc: support for setDialogTitle(). + 2008-09-28 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> * src/ygtkfindentry.h/c: added support embed context menu which pairs Modified: trunk/gtk/src/YGDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/YGDialog.cc (original) +++ trunk/gtk/src/YGDialog.cc Mon Sep 29 17:08:12 2008 @@ -5,6 +5,7 @@ #include <config.h> #include "YGUI.h" #include "YGDialog.h" +#include "YGUtils.h" #if YAST2_VERSION >= 2017006 #include <YDialogSpy.h> #endif @@ -36,8 +37,8 @@ GdkCursor *m_busyCursor; public: - YGWindowCloseFn m_canClose; - void *m_canCloseData; + YGWindowCloseFn m_canClose; + void *m_canCloseData; YGWindow (bool _main_window, YGDialog *ydialog) { @@ -312,6 +313,7 @@ YGWidget (this, NULL, FALSE, GTK_TYPE_HBOX, NULL) { setBorder (0); + m_stickyTitle = false; m_containee = gtk_event_box_new(); if (dialogType == YMainDialog && main_window) m_window = main_window; @@ -483,6 +485,31 @@ previousWidget = ywidget; } +void YGDialog::setTitle (const std::string &title, bool sticky) +{ + if (!m_stickyTitle || sticky) { + GtkWindow *window = GTK_WINDOW (m_window->getWidget()); + gchar *str; + if (title.empty()) + str = g_strdup ("YaST"); + else + str = g_strdup_printf ("%s - YaST", title.c_str()); + gtk_window_set_title (window, str); + g_free (str); + m_stickyTitle = sticky; + } +} + +void YGDialog::setIcon (const std::string &icon) +{ + GtkWindow *window = GTK_WINDOW (m_window->getWidget()); + GdkPixbuf *pixbuf = YGUtils::loadPixbuf (icon); + if (pixbuf) { + gtk_window_set_icon (window, pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + } +} + YDialog *YGWidgetFactory::createDialog (YDialogType dialogType, YDialogColorMode colorMode) { IMPL Modified: trunk/gtk/src/YGDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.h?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/YGDialog.h (original) +++ trunk/gtk/src/YGDialog.h Mon Sep 29 17:08:12 2008 @@ -12,6 +12,7 @@ friend class YGWindow; GtkWidget *m_containee; YGWindow *m_window; + bool m_stickyTitle; public: YGDialog (YDialogType dialogType, YDialogColorMode colorMode); @@ -40,6 +41,9 @@ virtual void highlight (YWidget * child); + void setTitle (const std::string &title, bool sticky = false); + void setIcon (const std::string &icon); + YGWIDGET_IMPL_CHILD_ADDED (m_containee) YGWIDGET_IMPL_CHILD_REMOVED (m_containee) }; Modified: trunk/gtk/src/YGDumbTab.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDumbTab.cc?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/YGDumbTab.cc (original) +++ trunk/gtk/src/YGDumbTab.cc Mon Sep 29 17:08:12 2008 @@ -51,8 +51,10 @@ if (item->hasIconName()) { string path = iconFullPath (item->iconName()); GdkPixbuf *pixbuf = YGUtils::loadPixbuf (path); - if (pixbuf) + if (pixbuf) { image = gtk_image_new_from_pixbuf (pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + } } if (image) { tab_label = gtk_hbox_new (FALSE, 6); Modified: trunk/gtk/src/YGMenuButton.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGMenuButton.cc?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/YGMenuButton.cc (original) +++ trunk/gtk/src/YGMenuButton.cc Mon Sep 29 17:08:12 2008 @@ -38,8 +38,10 @@ if ((*it)->hasIconName()) { GdkPixbuf *pixbuf = YGUtils::loadPixbuf ((*it)->iconName()); - if (pixbuf) + if (pixbuf) { image = gtk_image_new_from_pixbuf (pixbuf); + g_object_unref (G_OBJECT (pixbuf)); + } } if (image) { Modified: trunk/gtk/src/YGUtils.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.h?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/YGUtils.h (original) +++ trunk/gtk/src/YGUtils.h Mon Sep 29 17:08:12 2008 @@ -42,6 +42,8 @@ /* Sets some widget font proprities. */ void setWidgetFont (GtkWidget *widget, PangoWeight weight, double scale); + /* Saves some code and standardizes the error. Returns NULL if failed. + Don't forget to g_object_unref it! */ GdkPixbuf *loadPixbuf (const std::string &fileneme); /* Tries to make sense out of the string, applying some stock icon to the button. */ Modified: trunk/gtk/src/YGWizard.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWizard.cc?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/YGWizard.cc (original) +++ trunk/gtk/src/YGWizard.cc Mon Sep 29 17:08:12 2008 @@ -13,13 +13,6 @@ #include "YReplacePoint.h" #include "YGDialog.h" - -// FIXME: wizard events need to be ported -// We'll probably want to also make YGtkWizard buttons actual YGPushButtons... -// (let's just create them and pass button->getWidget() to the wizard...) -// (or let's just improve on the wrapper and id.) - - class YGWizard : public YWizard, public YGWidget { YReplacePoint *m_replacePoint; @@ -135,7 +128,8 @@ virtual ~YGWizard() { - // m_back/abort/next_button are added as children and will be freed by ~YContainerWidget + // m_back/abort/next_button are added as children and + // so will be freed by ~YContainerWidget } inline YGtkWizard *getWizard() @@ -165,11 +159,18 @@ { if (!ygtk_wizard_set_header_icon (getWizard(), icon.c_str())) yuiWarning() << "YGWizard: could not load image: " << icon << endl; + YGDialog::currentDialog()->setIcon (icon); } virtual void setDialogHeading (const string &heading) { ygtk_wizard_set_header_text (getWizard(), heading.c_str()); + YGDialog::currentDialog()->setTitle (heading, false); + } + + virtual void setDialogTitle (const string &title) + { + YGDialog::currentDialog()->setTitle (title, true); } virtual void addStep (const string &text, const string &id) Modified: trunk/gtk/src/ygtkwizard.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=51671&r1=51670&r2=51671&view=diff ============================================================================== --- trunk/gtk/src/ygtkwizard.c (original) +++ trunk/gtk/src/ygtkwizard.c Mon Sep 29 17:08:12 2008 @@ -308,11 +308,6 @@ static void ygtk_wizard_header_set_icon (YGtkWizardHeader *header, GdkPixbuf *pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (header->icon), pixbuf); } -static const gchar *ygtk_wizard_header_get_title (YGtkWizardHeader *header) -{ return gtk_label_get_text (GTK_LABEL (header->title)); } -static GdkPixbuf *ygtk_wizard_header_get_icon (YGtkWizardHeader *header) -{ return gtk_image_get_pixbuf (GTK_IMAGE (header->icon)); } - //** YGtkWizard // callbacks @@ -698,30 +693,9 @@ return TRUE; } -static void sync_window_title (YGtkWizard *wizard) -{ - GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (wizard)); - if (GTK_WIDGET_TOPLEVEL (window)) { - const gchar *_title = ygtk_wizard_header_get_title ( - YGTK_WIZARD_HEADER (wizard->m_title)); - char *title; - if (*_title == '\0') - title = g_strdup ("YaST"); - else - title = g_strdup_printf ("%s - YaST", _title); - GdkPixbuf *pixbuf = ygtk_wizard_header_get_icon ( - YGTK_WIZARD_HEADER (wizard->m_title)); - - gtk_window_set_title (GTK_WINDOW (window), title); - gtk_window_set_icon (GTK_WINDOW (window), pixbuf); - g_free (title); - } -} - void ygtk_wizard_set_header_text (YGtkWizard *wizard, const char *text) { ygtk_wizard_header_set_title (YGTK_WIZARD_HEADER (wizard->m_title), text); - sync_window_title (wizard); } gboolean ygtk_wizard_set_header_icon (YGtkWizard *wizard, const char *icon) @@ -732,7 +706,6 @@ return FALSE; ygtk_wizard_header_set_icon (YGTK_WIZARD_HEADER (wizard->m_title), pixbuf); g_object_unref (G_OBJECT (pixbuf)); - sync_window_title (wizard); return TRUE; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rpmcruz@svn.opensuse.org