Advertisement
Guest User

Untitled

a guest
May 6th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.50 KB | None | 0 0
  1. diff --git a/gnome-terminal.css b/gnome-terminal.css
  2. new file mode 100644
  3. index 0000000..8f9650d
  4. --- /dev/null
  5. +++ b/gnome-terminal.css
  6. @@ -0,0 +1,27 @@
  7. +.gnome-terminal-header-bar-ex {
  8. + border-bottom:none;
  9. +}
  10. +
  11. +.gnome-terminal-action-box {
  12. + padding: 3px 6px 0px 300px;
  13. + border:none;
  14. + box-shadow: inset 0 -1px shade(@wm_bg_b, 0.95);
  15. + background-color: @theme_bg_color;
  16. +}
  17. +
  18. +.gnome-terminal-action-box:backdrop {
  19. + box-shadow:none;
  20. + background-color: @theme_unfocused_bg_color;
  21. +}
  22. +
  23. +.gnome-terminal-notebook.notebook.header,
  24. +.gnome-terminal-notebook.notebook.header:backdrop {
  25. + background-color:transparent;
  26. + box-shadow:none;
  27. +}
  28. +
  29. +.gnome-terminal-notebook.notebook tab,
  30. +.gnome-terminal-notebook.notebook tab:backdrop {
  31. + background-color:transparent;
  32. + box-shadow: inset 0 3px alpha(black,0.03),inset 0 2px alpha(black,0.03),inset 0 1px alpha(black,0.03);
  33. +}
  34. diff --git a/src/terminal-notebook.c b/src/terminal-notebook.c
  35. index 5862949..8c13fab 100644
  36. --- a/src/terminal-notebook.c
  37. +++ b/src/terminal-notebook.c
  38. @@ -45,18 +45,6 @@ enum
  39. /* helper functions */
  40.  
  41. static void
  42. -update_tab_visibility (GtkNotebook *notebook,
  43. - int change)
  44. -{
  45. - gboolean show_tabs;
  46. - guint num;
  47. -
  48. - num = gtk_notebook_get_n_pages (notebook);
  49. - show_tabs = (num + change) > 1;
  50. - gtk_notebook_set_show_tabs (notebook, show_tabs);
  51. -}
  52. -
  53. -static void
  54. close_button_clicked_cb (TerminalTabLabel *tab_label,
  55. TerminalNotebook *notebook)
  56. {
  57. @@ -84,8 +72,6 @@ terminal_notebook_add_screen (TerminalMdiContainer *container,
  58. screen_container = terminal_screen_container_new (screen);
  59. gtk_widget_show (screen_container);
  60.  
  61. - update_tab_visibility (gtk_notebook, +1);
  62. -
  63. tab_label = terminal_tab_label_new (screen);
  64. g_signal_connect (tab_label, "close-button-clicked",
  65. G_CALLBACK (close_button_clicked_cb), notebook);
  66. @@ -112,8 +98,6 @@ terminal_notebook_remove_screen (TerminalMdiContainer *container,
  67.  
  68. g_warn_if_fail (gtk_widget_is_ancestor (GTK_WIDGET (screen), GTK_WIDGET (notebook)));
  69.  
  70. - update_tab_visibility (GTK_NOTEBOOK (notebook), -1);
  71. -
  72. screen_container = terminal_screen_container_get_from_screen (screen);
  73. gtk_container_remove (GTK_CONTAINER (notebook),
  74. GTK_WIDGET (screen_container));
  75. @@ -275,7 +259,6 @@ terminal_notebook_page_added (GtkNotebook *notebook,
  76. if (page_added)
  77. page_added (notebook, child, page_num);
  78.  
  79. - update_tab_visibility (notebook, 0);
  80. g_signal_emit_by_name (notebook, "screen-added",
  81. terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (child)));
  82. }
  83. @@ -291,7 +274,6 @@ terminal_notebook_page_removed (GtkNotebook *notebook,
  84. if (page_removed)
  85. page_removed (notebook, child, page_num);
  86.  
  87. - update_tab_visibility (notebook, 0);
  88. g_signal_emit_by_name (notebook, "screen-removed",
  89. terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (child)));
  90. }
  91. @@ -412,7 +394,7 @@ terminal_notebook_constructed (GObject *object)
  92.  
  93. G_OBJECT_CLASS (terminal_notebook_parent_class)->constructed (object);
  94.  
  95. - gtk_notebook_set_show_tabs (notebook, FALSE);
  96. + gtk_notebook_set_show_tabs (notebook, TRUE);
  97. gtk_notebook_set_scrollable (notebook, TRUE);
  98. gtk_notebook_set_show_border (notebook, FALSE);
  99. gtk_notebook_set_group_name (notebook, I_("gnome-terminal-window"));
  100. diff --git a/src/terminal-window.c b/src/terminal-window.c
  101. index db06b3f..dbd9110 100644
  102. --- a/src/terminal-window.c
  103. +++ b/src/terminal-window.c
  104. @@ -87,6 +87,12 @@ struct _TerminalWindowPrivate
  105.  
  106. /* Workaround until gtk+ bug #535557 is fixed */
  107. guint icon_title_set : 1;
  108. +
  109. + guint drag_possible : 1;
  110. +
  111. + gint button_press_x;
  112. + gint button_press_y;
  113. + guint32 button_press_time;
  114. };
  115.  
  116. #define PROFILE_DATA_KEY "GT::Profile"
  117. @@ -2407,6 +2413,104 @@ terminal_window_encoding_list_changed_cb (TerminalApp *app,
  118. terminal_window_update_encoding_menu (window);
  119. }
  120.  
  121. +static inline gboolean
  122. +in_double_click_range (GtkWidget *widget,
  123. + GdkEventButton *event)
  124. +{
  125. + TerminalWindowPrivate *priv = TERMINAL_WINDOW (widget)->priv;
  126. + gint double_click_time;
  127. + gint double_click_distance;
  128. +
  129. + g_object_get (gtk_widget_get_settings (widget),
  130. + "gtk-double-click-time", &double_click_time,
  131. + "gtk-double-click-distance", &double_click_distance,
  132. + NULL);
  133. +
  134. + if (event->time < priv->button_press_time + double_click_time &&
  135. + ABS (event->x_root - priv->button_press_x) <= double_click_distance &&
  136. + ABS (event->y_root - priv->button_press_y) <= double_click_distance)
  137. + return TRUE;
  138. +
  139. + return FALSE;
  140. +}
  141. +
  142. +static void
  143. +_gtk_window_toggle_maximized (TerminalWindow *window)
  144. +{
  145. + if (gtk_window_is_maximized(GTK_WINDOW(window)))
  146. + gtk_window_unmaximize (GTK_WINDOW(window));
  147. + else
  148. + gtk_window_maximize (GTK_WINDOW(window));
  149. +}
  150. +
  151. +static gint
  152. +action_box_motion_notify_event (GtkWidget *widget,
  153. + GdkEventMotion *event,
  154. + gpointer user_data)
  155. +{
  156. + TerminalWindow *window = TERMINAL_WINDOW(user_data);
  157. + TerminalWindowPrivate *priv = TERMINAL_WINDOW (window)->priv;
  158. +
  159. + if (!priv->drag_possible)
  160. + return FALSE;
  161. +
  162. + if (!in_double_click_range (GTK_WIDGET(window), (GdkEventButton *)event))
  163. + {
  164. + gdk_window_begin_move_drag_for_device (gtk_widget_get_window (GTK_WIDGET(window)),
  165. + gdk_event_get_device ((GdkEvent *)event),
  166. + GDK_BUTTON_PRIMARY,
  167. + event->x_root,
  168. + event->y_root,
  169. + event->time);
  170. + priv->drag_possible = FALSE;
  171. + return TRUE;
  172. + }
  173. +
  174. + return FALSE;
  175. +}
  176. +
  177. +static gint
  178. +action_box_button_release_event (GtkWidget *widget,
  179. + GdkEventButton *event,
  180. + gpointer user_data)
  181. +{
  182. + TerminalWindow *window = TERMINAL_WINDOW(user_data);
  183. + TerminalWindowPrivate *priv = TERMINAL_WINDOW (window)->priv;
  184. +
  185. + priv->drag_possible = FALSE;
  186. +
  187. + return FALSE;
  188. +}
  189. +
  190. +
  191. +static gint
  192. +action_box_button_press_event (GtkWidget *widget,
  193. + GdkEventButton *event,
  194. + gpointer user_data)
  195. +{
  196. + TerminalWindow *window = TERMINAL_WINDOW(user_data);
  197. + TerminalWindowPrivate *priv = TERMINAL_WINDOW (window)->priv;
  198. + if (event->type != GDK_BUTTON_PRESS)
  199. + return FALSE;
  200. + if (event->button == GDK_BUTTON_PRIMARY)
  201. + {
  202. + if (in_double_click_range ( GTK_WIDGET(window), event))
  203. + {
  204. + _gtk_window_toggle_maximized (window);
  205. + return TRUE;
  206. + }
  207. + else
  208. + {
  209. + priv->drag_possible = TRUE;
  210. + priv->button_press_x = event->x_root;
  211. + priv->button_press_y = event->y_root;
  212. + priv->button_press_time = event->time;
  213. + return TRUE;
  214. + }
  215. + }
  216. + return FALSE;
  217. +}
  218. +
  219. static void
  220. terminal_window_init (TerminalWindow *window)
  221. {
  222. @@ -2686,6 +2790,35 @@ terminal_window_init (TerminalWindow *window)
  223. gtk_box_pack_end (GTK_BOX (main_vbox), GTK_WIDGET (priv->mdi_container), TRUE, TRUE, 0);
  224. gtk_widget_show (GTK_WIDGET (priv->mdi_container));
  225.  
  226. + /* Create headerbar */
  227. + {
  228. + GtkWidget *headerbar,*eb, *action_box,*close_button;
  229. + headerbar = gtk_frame_new(NULL);
  230. + gtk_widget_show(headerbar);
  231. + gtk_style_context_add_class (gtk_widget_get_style_context (headerbar),"header-bar");
  232. + gtk_style_context_add_class (gtk_widget_get_style_context (headerbar),"gnome-terminal-header-bar-ex");
  233. + eb = gtk_event_box_new();
  234. + action_box = gtk_frame_new(NULL);
  235. + gtk_style_context_add_class (gtk_widget_get_style_context (action_box),"gnome-terminal-action-box");
  236. + close_button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU);
  237. + gtk_widget_set_valign (close_button, GTK_ALIGN_START);
  238. + gtk_widget_set_can_focus (close_button, FALSE);
  239. + gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
  240. + gtk_style_context_add_class (gtk_widget_get_style_context (close_button), "titlebutton");
  241. + g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_window_close), window);
  242. + gtk_container_add(GTK_CONTAINER(action_box),close_button);
  243. + gtk_container_add( GTK_CONTAINER(eb), action_box );
  244. + gtk_widget_set_events(eb,GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
  245. + g_signal_connect(eb, "button_press_event", G_CALLBACK (action_box_button_press_event), window);
  246. + g_signal_connect(eb, "button_release_event", G_CALLBACK (action_box_button_release_event), window);
  247. + g_signal_connect(eb, "motion_notify_event", G_CALLBACK (action_box_motion_notify_event), window);
  248. + gtk_widget_show_all(eb);
  249. + gtk_notebook_set_action_widget(GTK_NOTEBOOK(priv->mdi_container),eb,GTK_PACK_END);
  250. + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(priv->mdi_container)),"gnome-terminal-notebook");
  251. + gtk_window_set_titlebar (GTK_WINDOW (window),headerbar);
  252. + }
  253. +
  254. +
  255. priv->old_char_width = -1;
  256. priv->old_char_height = -1;
  257. priv->old_geometry_widget = NULL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement